/*
 * Created by SharpDevelop.
 * Author: Joey
 * Date: 26/09/2007
 * Time: 01:05
 * 
 * Source is copyright Joey Sabey 2007
 */

using System;
using System.Drawing;
using System.Windows.Forms;

namespace MonoTheism
{
	/// <summary>
	/// Description of Dependency_Properties.
	/// </summary>
	public partial class Dependency_Properties : Form
	{
		private bool bAcceptChanges = false;
		public bool AcceptChanges
		{
			get{return bAcceptChanges;}
		}
		public string FileName
		{
			get{return txtDepFile.Text;}
		}
		public int Category
		{
			get{return System.Int32.Parse(txtDepCategory.Text);}
		}
		public bool Embed
		{
			get{return chkEmbed.Checked;}
		}
		
		public Dependency_Properties()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
		}
		public Dependency_Properties(Dependency dep)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			txtDepFile.Text = dep.FileName;
			txtDepCategory.Text = dep.Category.ToString();
		}
		
		void BtCancelClick(object sender, EventArgs e)
		{
			Close();
		}
		
		void BtOkClick(object sender, EventArgs e)
		{
			bAcceptChanges = true;
			Close();
		}
		
		void BtBrowseClick(object sender, EventArgs e)
		{
			OpenFileDialog ofdSelectFile = new OpenFileDialog();
			ofdSelectFile.Filter = "All Files|*.*|"
								 + "CAOS Files|*.cos|"
								 + "Sprite Files|*.s16|"
								 + "Compressed Sprite Files|*.c16|"
								 + "Sound Files|*.wav|"
								 + "Catalogue Files|*.catalogue";
			ofdSelectFile.ShowDialog();
			
			txtDepFile.Text = System.IO.Path.GetFileName(ofdSelectFile.FileName);
			
			string sFileExt = System.IO.Path.GetExtension(ofdSelectFile.FileName).ToLower();
			if(sFileExt == ".wav")
				txtDepCategory.Text = "1";
			else if(sFileExt == ".c16" | sFileExt == ".s16")
				txtDepCategory.Text = "2";
			else if(sFileExt == ".catalogue")
				txtDepCategory.Text = "7";
			else
				txtDepCategory.Text = "0";
		}
	}
}
